package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.goodssku.GoodsSkuBO;
import com.micro.modual.model.dto.goodssku.GoodsSkuDetailDTO;
import com.micro.modual.model.dto.goodssku.GoodsSkuListDTO;
import com.micro.modual.service.GoodsSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>商品sku表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "商品SKU管理",tags = "商品SKU管理")
@RestController
@RequestMapping(value = "sku")
public class GoodsSkuController {

    @Autowired
    private GoodsSkuService goodsSkuService;

    /**
     * <h2>查找商品sku表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<GoodsSkuListDTO> {@link GoodsSkuListDTO}s  商品sku表 列表返回对象
     */
    @ApiOperation(value = "查询商品sku表列表" ,notes = "查询商品sku表列表")
    @GetMapping(value = "/findGoodsSkuList")
    public RespJsonPageData<GoodsSkuListDTO> findGoodsSkuList(@RequestParam  Map<String,Object> params){
        return goodsSkuService.findGoodsSkuList(params);
    }

    /**
     * <h2>根据主键编号查看商品sku表详情</h2>
     * @param id  商品sku表 主键编号
     * @return {@link GoodsSkuDetailDTO}  商品sku表 详情
     */
    @ApiOperation(value = "查询商品sku表详情",notes = "根据主键编号，查询商品sku表详情")
    @GetMapping(value = "/findGoodsSkuDetail/{id}")
    public RespJsonData<GoodsSkuDetailDTO> findGoodsSkuDetail(@PathVariable("id") Long id){
        return goodsSkuService.findDetail(id,GoodsSkuDetailDTO.class);
    }


    /**
     * <h2>修改商品sku表详情</h2>
     * @param goodsSkuBO  {@link GoodsSkuBO} 商品sku表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改商品sku表",notes = "修改商品sku表")
    @PostMapping(value = "/editGoodsSku")
    public RespJson editGoodsSku(@RequestBody GoodsSkuBO goodsSkuBO){
        return goodsSkuService.editGoodsSku(goodsSkuBO);
    }

    /**
     * <h2>根据主键编号删除商品sku表信息</h2>
     * @param id  商品sku表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除商品sku表",notes = "根据地址ID，删除商品sku表")
    @PostMapping(value = "/deleteGoodsSku/{id}")
    public RespJson deleteGoodsSku(@PathVariable("id") Long id){
        return goodsSkuService.deleteGoodsSku(id);
    }
}

